<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>规划阶段</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">

<link rel="stylesheet" href="css/vivo.css">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css"href="js/webuploader-0.1.5/webuploader.css" />

<script src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<script type="text/javascript"
	src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
<script src="js/select2/select2.min.js"></script>
<script src="js/sharefunction.js"></script>

<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript" src="js/sharefunction.js"></script>
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js"></script>

<style type="text/css">
</style>
</head>

<script type="text/javascript">
	var acIds ="";//新增附件id集合
	var caList = ${requestScope.caList};
	$(function() {
		//修改字段标记记录变量
		<c:set var="marks" value="原数据"/>
		//详规指标数据填写
		initSelectData();
		//设置用地性质默认值
		var planLandPropertyS2=$("#planLandProperty").select2({
			tags : true
		});
		//设置用地性质默认值
		planLandPropertyS2.val("${requestScope.planStage.planLandProperty }").trigger("change");
		initPicEditData();
		getFiles();
		//鼠标划过悬浮框
		toolTip();
		
	});
	//获取编辑页面图片的数据
	function initPicEditData(){
		var fujians = ${requestScope.fujianList};
		html="";
		 //原数据的图片（不包括删除的图片）
		$.each(fujians, function(i,val) {
			if(val != null && val !="" && val != undefined){
				var html = "<tr><td style='width: 120px;'>" + val.article + "</td><td><!--上传附件部分--><div style='display: inline-block;'><div id='list_" + val.id + "'></div><div id='file_" + val.id + "'>上传</div></div><a href='javascript:void(0)'onclick='delTrPlan(this)'><i class='icon-fullscreen'></i></a></td>";
				//添加html元素
				$("#addtrtable").append(html);
			}
		});  
	}
	
	
	//展示附件
	var id = '${planStage.id}';
	function getFiles() {
		var fujians = ${requestScope.fujianList};
		$.each(fujians, function(i,val) {
			//原数据的图片（不包括删除的图片）
			getFileListByFlag(id, val.id, 2,"#list_"+val.id, setRFL,imgPlus);
			<c:if test="${requestScope.notPassExamine}"> 
				//获取序列化操作时的图片数据
				for(var j = 0;j<caList.length;j++){
					if(val.id == caList[j].articleId){
						getFileListByAcId(caList[j].accessoryCAId,"#list_"+val.id,imgPlus);
					}
				} 
			</c:if>
		});
		
	}
	var rFileList=new Array();//
	//设置待删除附件的值到集合中
	function setRFL(id,_this){
		layer.confirm('删除该图片？',{
			title:'警告',
			icon:0,
			shade:[0.1, '#fff']
		},function(){
			rFileList.push(id);
			//删除指定缩略图
			$("#"+id).remove();
			layer.close(layer.index);
		});
	}
	
	function imgPlus(data) {
		$.each(data, function(i, v) {
			//图片放大
			PostbirdImgGlass.init({
				domSelector : "#" + v.id + " img",
				animation : true,
				myDocument : window.parent.parent.parent
			});
		});
		$("#planStageForm .uploadcancel").css("display","none");
	}

	function initSelectData() {
		$.getJSON("dictionariesArticle/getDictionariesArticle", {
			classifyId : "规划阶段",
			direction : ""
		}, function(data, status) {
			if (status == "success") {
				$.each(data, function(i, v) {
					var html ="";
					if(v){
						html = "<option value=\"" + v.id + "\">" + v.article + "</option>";
						$("#planIndicator").append(html);
					}
				});
				
			}
			 $("#planIndicator").select2({
					tags : true
				});
		});
	}
</script>
<body>
	<div style="padding:0px 10px">
		<form id="planStageForm" method="post" onsubmit="return false;">
			<!-- 上传文件返回的附件id -->
			<input type="text" id="planStage_articleId"
				name="planStage_articleId" value="" hidden="hidden"
				style="display: none;" />

			<div class="panel panel-default">
				<div class="panel-heading">
					<h5 class="panel-title">控规指标</h5>
				</div>
				<div class="panel-body">
					<table cellpadding="10" cellspacing="5" class="mytable">
						<tr>
							<td width="70" class="td-right">规划时间</td>
							<td width="300"><input id="planDate" name="planDate" class="Wdate"
								value="<fmt:formatDate value="${requestScope.planStage.planDate }" pattern="yyyy-MM-dd" />"
								onClick="WdatePicker()" />
								<c:if test="${not empty requestScope.map.planDate }"><span class="toolTip mark-msg" data-tip="<fmt:formatDate  value="${requestScope.map.planDate }" type="both" pattern="yyyy-MM-dd" />">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="70" class="td-right">规划名称</td>
							<td><input name="planName" class="toolTip" data-tip="${requestScope.planStage.planName }" value="${requestScope.planStage.planName }" />
								<c:if test="${not empty requestScope.map.planName }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planName }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="70" class="td-right">占地面积</td>
							<td><input name="planArea"
								value="<fmt:formatNumber value="${requestScope.planStage.planArea }" pattern="0.00"/>" /> ㎡
								<c:if test="${not empty requestScope.map.planArea }"><span class="toolTip mark-msg" data-tip="<fmt:formatNumber value="${requestScope.map.planArea }" pattern="0.00"/>">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="70" class="td-right">建筑密度</td>
							<td><input name="planBuildingDensity"
								value="<fmt:formatNumber value="${requestScope.planStage.planBuildingDensity }" pattern="0.00"/>" /> %
								<c:if test="${not empty requestScope.map.planBuildingDensity }"><span class="toolTip mark-msg" data-tip="<fmt:formatNumber value="${requestScope.map.planBuildingDensity }" pattern="0.00"/>">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="70" class="td-right">用地性质</td>
							<td><select id="planLandProperty" name="planLandProperty"
								style="width:130px;">
									<option value="" selected="selected" >请选择</option>
									<c:forEach items="${landPropertyList }" var="p">
										<option value="${p }" selected>${p }</option>
									</c:forEach>
								</select>
								<c:if test="${not empty requestScope.map.planLandProperty }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planLandProperty }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="70" class="td-right">限制高度</td>
							<td><input name="planMaxHeight"
								value="<fmt:formatNumber value="${requestScope.planStage.planMaxHeight }" pattern="0.00"/>" /> m
								<c:if test="${not empty requestScope.map.planMaxHeight }"><span class="toolTip mark-msg" data-tip="<fmt:formatNumber value="${requestScope.map.planMaxHeight }" pattern="0.00"/>">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="70" class="td-right">绿化率</td>
							<td><input name="planAfforest"
								value="<fmt:formatNumber value="${requestScope.planStage.planAfforest }" pattern="0.00"/>" /> %
								<c:if test="${not empty requestScope.map.planAfforest }"><span class="toolTip mark-msg" data-tip="<fmt:formatNumber value="${requestScope.map.planAfforest }" pattern="0.00"/>">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td width="70" class="td-right">容积率</td>
							<td colspan="3"><input name="planVolume"
								value="<fmt:formatNumber value="${requestScope.planStage.planVolume }" pattern="0.00"/>" /> %
								<c:if test="${not empty requestScope.map.planVolume }"><span class="toolTip mark-msg" data-tip="<fmt:formatNumber value="${requestScope.map.planVolume }" pattern="0.00"/>">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="70" class="td-right">四至红线</td>
							<td colspan="2">东至&nbsp;<input style="width: 270px;"
								name="planEast" value="${requestScope.planStage.planEast }" />
								<c:if test="${not empty requestScope.map.planEast }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planEast }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td></td>
							<td colspan="2">西至&nbsp;<input style="width: 270px;"
								name="planWest" value="${requestScope.planStage.planWest }" />
								<c:if test="${not empty requestScope.map.planWest }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planWest }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
						<tr>
							<td width="70"></td>
							<td colspan="2">南至&nbsp;<input style="width: 270px;"
								name="planSouth" value="${requestScope.planStage.planSouth }" />
								<c:if test="${not empty requestScope.map.planSouth }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planSouth }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
							<td></td>
							<td colspan="2">北至&nbsp;<input style="width: 270px;"
								name="planNorth" value="${requestScope.planStage.planNorth }" />
								<c:if test="${not empty requestScope.map.planNorth }"><span class="toolTip mark-msg" data-tip="${requestScope.map.planNorth }">
									<c:out value="${marks}"/></span>
								</c:if>
							</td>
						</tr>
					</table>
				</div>
			</div>

			<div class="panel panel-default">
				<div class="panel-heading">
					<h5 class="panel-title">详规指标</h5>
				</div>
				<div class="panel-body">
					<p>
						<span class="style_btn">详规指标</span> <span class="style_input">
							<select class="js-example-basic-single" name="planIndicator"
							id="planIndicator" style="width:160px;">
						</select>
						</span> <a class="btn btn-danger radius" onclick="addTrPlan()" name="addXGZB"> 添加</a>
					</p>
					<table id="addtrtable" cellpadding="10" cellspacing="5" class="mytable">

					</table>
				</div>
			</div>
			<c:if test="${requestScope.notPassExamine}">
				<!-- 修改时添加变更说明 -->
				<div style="margin:10px;"  id="changeRemark">
					备注<textarea rows="3" name="changeRemark"style="width:70%"></textarea><span style="color:red;">*</span>
				</div>
				<div style="width:100%;text-align:center; padding-top:0px">
					<button class="btn btn-danger radius my-btn" type="button" onclick="saveDocument(0)">同意</button>
					<button class="btn btn-default radius" type="button" onclick="saveDocument(1)">拒绝</button>
					<br />
				</div>
			</c:if>
		</form>
	</div>

	<script type="text/javascript">
		$(function() {
			//如果已经保存过了，则开启只读状态
			<c:if test="${not empty requestScope.planStage }">
				$("#planStageForm").find("input").attr("readonly",true);
				$("#planStageForm").find("select").attr("disabled",true);
				$("#planStageForm .icon-fullscreen").hide();
				$("#planStageForm .Wdate,[name='addXGZB']").attr("disabled",true);
				$("#planStageForm div[id^='file']").unbind("click").click(function(){
			        return false;
			    }).hide();
			</c:if>
			
		});
		
		function saveDocument(opt){
			var url = "project/approval/disposePlan";
			var apId = '${requestScope.apId }';
			var exDataId = '${exDataId}';
			var changeRemark = $("#planStageForm textarea[name='changeRemark']").val();
			if(apId!="" && apId!=null && apId!=undefined){
				if(changeRemark==""){
					layer.alert("审批说明不能为空");
					layer.close(i);
					return null;
				}
			}
			var formData = {
					exDataId:exDataId,
		        	opt:opt,
		        	apId:apId,
		        	approvalRemark:changeRemark
		    };
			disposeSave(opt,url,formData);
		}
		
		/* function saveDocument(val) {
			var id = $("#planStageForm #entityId_id").val();
			var apId = $("#planStageForm #apId").val();//approval_pending 表id
			var changeRemark = $("#planStageForm textarea[name='changeRemark']").val();
			if(id!="" && id!=null && id!=undefined){
				if(changeRemark==""){
					layer.alert("变更说明不能为空");
					return false;
				}
			}
			var url = "project/approval/disposePlan";
			jQuery.ajax({
				type : "post",
				async : false,
				url : url,
				dataType : "json",
				data : {
					newEntityId:id,
					apId:apId,
					approvalRemark:changeRemark,
					opt:val
				},
				success : function(data) {
					if (data.success) {
						alert(data.msg);
						parent.location.reload();
						parent.parent.getPendingCount();
						parent.parent.getPendingPassCount();
						parent.parent.getPendingBackCount();
						bnClose();
					} else {
						alert(data.msg);
					}
				}
			});
		} */
		
		//关闭当前窗体
		function bnClose() {
			parent.layer.closeAll();
		} 

	</script>
</body>
</html>

